package com.juhuixing.es.server.swagger;

import com.juhuixing.common.swagger.SwaggerUtil;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.forCodeGeneration(true)
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.juhuixing.es.server.controller"))
				.paths(PathSelectors.any())
				.build()
				.securitySchemes(SwaggerUtil.securitySchemes())
				.securityContexts(SwaggerUtil.securityContexts());
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("嗅嗅App ES接口文档")
				.description("嗅嗅App ES接口文档")
				.termsOfServiceUrl("")
				.contact(new Contact("刘猛","635891879@qq.com","635891879@qq.com"))
				.version("2.0")
				.build();
	}

}